#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import time


def timeit(func):
    def wrapper(*args, **kwargs):
        start = time.clock()
        print(func(*args, **kwargs))
        end = time.clock()
        print('used:%f' % (end - start))
    return wrapper


@timeit
def bubble_sort(li):
    try:
        for i in range(len(li) - 1):
            for j in range(len(li) - i - 1):
                if li[j] > li[j + 1]:
                    temp = li[j]
                    li[j] = li[j + 1]
                    li[j + 1] = temp
    except Exception as e:
        print("Exception:", e)
        return None
    else:
        return li

@timeit
def insert_sort(li):
    try:
        for i in range(1, len(li)):
            for j in range(i):
                if li[j] > li[i]:
                    li.insert(j, li[i])
                    li.pop(i + 1)
    except Exception as e:
        print("Exception:", e)
        return None
    else:
        return li

